package com.loup.executor;

import com.loup.configure.LoupConfiguration;
import com.loup.jdbc.LoupConnection;

import java.sql.Connection;

/**
 * Created by loup on 2018/4/26.
 */
public class LoupExecutor implements Executor {


    public <T> T query(String statement, String param,Class rt) {

        LoupConnection loupConnection = new LoupConnection();
        try {
            Connection con = loupConnection.getConnection(LoupConfiguration.getUrl(), LoupConfiguration.getClassName(), LoupConfiguration.getUserName(), LoupConfiguration.getPassword());
            return (T) loupConnection.handler(con,String.format(statement,param),rt,new Object[]{param});
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
}
